package com.example.gaojt.androiddemo.boostDemo.aa;

import android.content.Context;
import android.content.res.Resources;

public class IniManager {

    public static final int PROCESS_UNCHECKED = 1;
    public static final int PROCESS_FILTERED = 2;
    public static final int PROCESS_UNCHECKED_WHEN_SCREENOFF = 3;
    public static final int PROCESS_FLEXIBLE_WHITE_LIST = 4;
    public static final int PROCESS_NECESSARY_APP = 6;

    /**
     * 获取flexible节点下内容
     */
    public static int getFlexibleValue(Context context, String pkgname) {
        return getInteger(context.getResources(), "f_" + pkgname, context.getPackageName(), 0);
    }

    /**
     * 获取process节点下内容
     */
    public static int getIniMark(Context context, String pkgname) {
        return getInteger(context.getResources(), "p_" + pkgname, context.getPackageName(), 0);
    }

    static int getInteger(Resources res, String name, String packageName, int defaultValue) {
        int id = res.getIdentifier(name, "integer", packageName);
        if (id > 0) {
            int value = res.getInteger(id);
            return value;
        }
        return defaultValue;
    }

}
